{% extends 'iframe/basePlus.html.twig' %}
{% block cardHeader %}更新密码{% endblock %}
{% block cardBody %}
    <form class="layui-form">
        <dry-common role="password" label="原密码" name="dry_old_password" placeholder="请输入原密码"></dry-common>
        <dry-common role="password" label="新密码" name="dry_password" placeholder="请输入新密码" help="字母、数字、特殊符号必须包含2种，长度在9-16位"></dry-common>
        <dry-common role="password" label="确认新密码" name="dry_sure_password" placeholder="请输入确认新密码"></dry-common>
        <input type="hidden" name="device" id="device" value="">
        <input type="hidden" name="token" id="token" value="">
        <dry-common role="submit" submit="确定" reset="重置"></dry-common>
    </form>
    <script>
        layui.use(["dry", "jquery", "cookies"], function(dry, $, cookies){
            function getVerify()
            {
                var result = {};
                result.dry_old_password = function(value){
                    if(value == ""){
                        return "请输入原密码";
                    }
                };
                result.dry_password = function(value){
                    if(value == ""){
                        return "请输入新密码";
                    }
                };
                result.dry_sure_password = function(value){
                    if(value == ""){
                        return "请输入确认新密码";
                    }
                    if(value != $("#dry_password").val()){
                        return "两次输入的密码不一致";
                    }
                };
                return result;
            }

            $("#device").val("admin");
            $("#token").val(cookies.getItem("token"));
            dry.submit(getVerify(), "", "/Api/User/updatePassword");
        });
    </script>
{% endblock %}